<!--#include file="common/header.html"-->
<body>
    <div class="container-fluid larry-wrapper">
        <div class="row">
            <div class="col-xs-12 col-sm-12 col-md-12">
                <!--头部搜索-->
                <section class="panel panel-padding">
                    <form class="layui-form" action="/education/admin/marquee">
                        <div class="layui-form">
                            <div class="layui-inline">
                                <select name="_query.type" id="marqueeType"
                                        data-params='{"url": "/education/admin/marquee"}'>
                                    <option value="1">商品</option>
                                    <option value="2">商品专场</option>
                                    <option value="3">网页</option>
                                </select>
                            </div>
                            <div class="layui-inline">
                                <div class="layui-input-inline">
                                    <input class="layui-input" name="_query.keyword" placeholder="关键字">
                                </div>
                            </div>
                            <div class="layui-inline">
                                <button lay-submit class="layui-btn" lay-filter="search">查找</button>
                            </div>
                        </div>
                    </form>
                </section>

                <!--列表-->
                <section class="panel panel-padding">

                    <div class="group-button">
                        
                        <button class="layui-btn layui-btn-small layui-btn-danger ajax-all" data-name="checkbox" data-params='{"url": "/education/admin/marquee/delete"}'>
                            <i class="iconfont">&#xe626;</i> 删除
                        </button>
                    </div>
                    <div id="list" class="layui-form"></div>

                    <div class="text-right" id="page"></div>
                </section>
            </div>
        </div>
    </div>

    <div class="edit-subcat">
        <form class="layui-form layui-form-pane" action="/education/admin/marquee/updateImg" id="form1">
            <input type="hidden" name="id">

            <div class="layui-form-item">
                <label class="layui-form-label" style="width:200px">封面图片</label>
                <div class="layui-input-block">
                    <input type="file" name="file" class="layui-upload-file" id="img">
                    <input type="hidden" name="image">
                </div>
                <div class="layui-input-inline"><div class="imgbox" style="width: 800px;"></div></div>
            </div>


            <div class="layui-form-item">
                <div class="layui-input-block">
                    <button class="layui-btn" jq-submit jq-filter="submit">立即提交</button>
                    <button type="reset" class="layui-btn layui-btn-primary">重置</button>
                </div>
            </div>
        </form>
    </div>
</body>
<!--#include file="marquee-list.html"-->
<script src="../js/layui/layui.js"></script>
<script type="text/javascript" src="../js/lib/jquery-1.11.2.min.js"></script>
<script type="text/javascript" src="../js/lib/rest.js"></script>

<!--#include file="common/version.html"-->
<script>
    layui.define(['jquery', 'dtable', 'jqdate', 'jqform', 'upload'], function(exports) {
        var $ = layui.jquery,
                list = layui.dtable,
                form = layui.jqform,
                oneList = new list();
        form.set({
            "change": true,
            "form": "#form1"
        }).init(oneList);

        var url = "/education/admin/marquee?_query.type=" + $('#marqueeType').val();

        $('#list-tpl').attr('data-params',
                '{"url":"'+url+'","dataName":"marqueeData","pageid":"#page", "method":"post"}');
        oneList.init('list-tpl');

    });

    layui.use(['jquery','upload'], function(exports) {
        var box;
        //上传文件设置
        layui.upload({
            elem: '#img',
            url: '/education/api/image/marquee',
            before: function (input) {
                box = $(input).parent('form').parent('div').parent('.layui-input-block');
                if (box.next('div').length > 0) {
                    box.next('div').html('<div class="imgbox"><p>上传中...</p></div>');
                } else {
                    box.after('<div class="layui-input-block"><div class="imgbox"><p>上传中...</p></div></div>');
                }
            },
            success: function (res) {
                if (res.code == 200) {
                    box.next('div').find('div.imgbox').html('<img src="/education' + res.data[0].url + '" alt="..." class="img-thumbnail">');
                    box.find('input[name=image]').val(res.data[0].url);
                } else {
                    box.next('div').find('p').html('上传失败...')
                }
            }
        });
    });


    function viewDetail(){
        var checked = $("input[name=checkbox]:checked");
        if(checked.length != 1){
            layer.msg('请选择一项待修改的数据');
            return;
        }
        var ids = checked.val();
        var index = layer.open({
            type: 1,
            title:'编辑',
            content: $('.add-subcat')
        });
        layer.full(index);
        $('#form1').attr('action', '/education/admin/marquee/update');
        restGet('/education/api/marquee/view/' + ids, null, $('#form1'), function(rs){
            if(rs.code == 200){
                ue.ready(function() {
                    //设置编辑器的内容
                    ue.setContent(rs.data.content);
                });
            }
        })
    }
</script>

</html>